<script setup>
    import {ref} from 'vue'
    import {onMounted} from 'vue'
    import chartApi from "@/api/chart.js";

    const userCount = ref(0)
    const patientCount = ref(0)
    const medicineCount = ref(0)
    const departmentCount = ref(0)

    //加载完后在进行
    onMounted(() => {
        chartApi.selectTotalCount().then((result) => {
            if (result.code === 0) {
                userCount.value = result.data.userCount
                patientCount.value = result.data.patientCount
                medicineCount.value = result.data.medicineCount
                departmentCount.value = result.data.departmentCount
            }
        })
    });
</script>

<template>
    <el-row>
        <el-col :span="6">
            <div class="title">员工数量</div>
            <div class="count mem">{{ userCount }}</div>
        </el-col>
        <el-col :span="6">
            <div class="title">患者数量</div>
            <div class="count coa">{{ patientCount }}</div>
        </el-col>
        <el-col :span="6">
            <div class="title">药品数量</div>
            <div class="count cou">{{ medicineCount }}</div>
        </el-col>
        <el-col :span="6">
            <div class="title">科室数量</div>
            <div class="count res">{{ departmentCount }}</div>
        </el-col>
    </el-row>
</template>

<style scoped>
    .title {
        text-align: center;
        height: 40px;
        line-height: 40px;
    }

    .count {
        margin: auto;
        width: 100px;
        height: 100px;
        border: 15px solid #49BCF7;
        border-radius: 50%;
        text-align: center;
        line-height: 100px;
        font-size: 30px;
    }

    .mem {
        border-color: #49BCF7;
        color: #49BCF7;
    }

    .coa {
        border-color: #91CC75;
        color: #91CC75;
    }

    .cou {
        border-color: #FAC858;
        color: #FAC858;
    }

    .res {
        border-color: #5470C6;
        color: #5470C6;
    }
</style>